%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plots Figures A.9
%
% need to run Stata Code MainRun.do first       
%
% Cloyne, Dimsdale and Hürtgen (2024) 								
%	"Are Tax Cuts Contractionary at the Zero Lower Bound? Evidence from a Century of Data"  	  		
%																			
% James Cloyne, Nicholas Dimsdale and Patrick Hürtgen, 2024
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all
close all
clc

OPTIONS.ShadedBands=1;

%% Average effect

f1  = fullfile('..\StataOutput\AE\FigureA9\','DataIRF_AE_realGDPToTax_smoothed_s_smoothed_Pair1.xlsx');
f2  = fullfile('..\StataOutput\AE\FigureA9\','DataIRF_AE_realGDPToTax_smoothed_s_smoothed_Pair2.xlsx');
f3  = fullfile('..\StataOutput\AE\FigureA9\','DataIRF_AE_realGDPToTax_smoothed_s_smoothed_Pair3.xlsx');
f4  = fullfile('..\StataOutput\AE\FigureA9\','DataIRF_AE_realGDPToTax_smoothed_s_smoothed_Pair4.xlsx');
f5  = fullfile('..\StataOutput\AE\FigureA9\','DataIRF_AE_realGDPToTax_smoothed_s_smoothed_Pair5.xlsx');
                                             
IRFa = xlsread(f5);
IRFb = xlsread(f1);
IRFc = xlsread(f2);
IRFd = xlsread(f3);
IRFe = xlsread(f4);

xmin=0;
xmax=13;
stepsize=1;

Sdep=0;
OPTIONS.H=xmax;
IRFa=IRFa(1:xmax,:);
IRFb=IRFb(1:xmax,:);

r_color = 235;
b_color = 235;
g_color = 255;

x = 0:1:OPTIONS.H-1;

myplot=figure(1);

if OPTIONS.ShadedBands==0
    lb68=plot(xmin:xmax-1,IRFa(:,3+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    ub68=plot(xmin:xmax-1,IRFa(:,4+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    lb95=plot(xmin:xmax-1,IRFa(:,5+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
    ub95=plot(xmin:xmax-1,IRFa(:,6+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
elseif OPTIONS.ShadedBands==1
    shadedplot(xmin:xmax-1,IRFa(:,3+Sdep)',IRFa(:,4+Sdep)',[r_color/255 b_color/255 g_color/255],[r_color/255 b_color/255 g_color/255]); hold on;
    plot(xmin:xmax-1,IRFa(:,5+Sdep),'b','MarkerSize',5); hold on;
    plot(xmin:xmax-1,IRFa(:,6+Sdep),'b','MarkerSize',5); hold on;
end

a=plot(xmin:xmax-1,IRFa(:,2+Sdep), 'b-o','LineWidth',2.5,'MarkerSize',8);hold on
b=plot(xmin:xmax-1,IRFb(:,2+Sdep),  '--','color','#2f7e2b','LineWidth',2.5,'MarkerSize',5);hold on
c=plot(xmin:xmax-1,IRFc(:,2+Sdep),  '--','color','y','LineWidth',2.5,'MarkerSize',5);hold on
d=plot(xmin:xmax-1,IRFd(:,2+Sdep),  '--','color','m','LineWidth',2.5,'MarkerSize',5);hold on
e=plot(xmin:xmax-1,IRFe(:,2+Sdep),  '--','color','cyan','LineWidth',2.5,'MarkerSize',5);hold on

plot([min(xlim()),max(xlim())],[0,0], 'k','LineWidth',0.25);

set(gca,'TickDir','in'); 
xlabel('Quarters');
set(gca,'YLIM', [-1 6]);
yticks([0 2 4 6 ])
set(gca,'XTick',[0:1:xmax-1 ])
set(gca,'XLIM', [-inf inf], 'FontSize',16)
box off; grid off;
set(gcf, 'Color', 'w');
legend([ a b c d e], '(4,4)','(1,1)','(1,2)','(2,4)','(1,4)', 'Orientation','Vertical','Location','northwest');
myplot.PaperPositionMode = 'manual';
set(myplot,'Position',[50 50 1200 800]);
orient(myplot,'landscape')

saveas(myplot, 'FigureA9a', 'pdf')
saveas(myplot, 'FigureA9a', 'epsc')

%% ZLB Regime

f1  = fullfile('..\StataOutput\StateDep\FigureA9\','DataIRF_S_realGDPToTax_smoothed_s_lnRealGDP_smoothed_Pair1.xlsx');
f2  = fullfile('..\StataOutput\StateDep\FigureA9\','DataIRF_S_realGDPToTax_smoothed_s_lnRealGDP_smoothed_Pair2.xlsx');
f3  = fullfile('..\StataOutput\StateDep\FigureA9\','DataIRF_S_realGDPToTax_smoothed_s_lnRealGDP_smoothed_Pair3.xlsx');
f4  = fullfile('..\StataOutput\StateDep\FigureA9\','DataIRF_S_realGDPToTax_smoothed_s_lnRealGDP_smoothed_Pair4.xlsx');
f5  = fullfile('..\StataOutput\StateDep\FigureA9\','DataIRF_S_realGDPToTax_smoothed_s_lnRealGDP_smoothed_Pair5.xlsx');

IRFa = xlsread(f5);
IRFb = xlsread(f1);
IRFc = xlsread(f2);
IRFd = xlsread(f3);
IRFe = xlsread(f4);

xmin=0;
xmax=13;
stepsize=1;

Sdep=5;
OPTIONS.H=xmax;
IRFa=IRFa(1:xmax,:);
IRFb=IRFb(1:xmax,:);

r_color = 235;
b_color = 235;
g_color = 255;

x = 0:1:OPTIONS.H-1;

myplot=figure(2);

if OPTIONS.ShadedBands==0
    lb68=plot(xmin:xmax-1,IRFa(:,3+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    ub68=plot(xmin:xmax-1,IRFa(:,4+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    lb95=plot(xmin:xmax-1,IRFa(:,5+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
    ub95=plot(xmin:xmax-1,IRFa(:,6+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
elseif OPTIONS.ShadedBands==1
    shadedplot(xmin:xmax-1,IRFa(:,3+Sdep)',IRFa(:,4+Sdep)',[r_color/255 b_color/255 g_color/255],[r_color/255 b_color/255 g_color/255]); hold on;
    plot(xmin:xmax-1,IRFa(:,5+Sdep),'b','MarkerSize',5); hold on;
    plot(xmin:xmax-1,IRFa(:,6+Sdep),'b','MarkerSize',5); hold on;
end

a=plot(xmin:xmax-1,IRFa(:,2+Sdep), 'b-o','LineWidth',2.5,'MarkerSize',8);hold on
b=plot(xmin:xmax-1,IRFb(:,2+Sdep),  '--','color','#2f7e2b','LineWidth',2.5,'MarkerSize',5);hold on
c=plot(xmin:xmax-1,IRFc(:,2+Sdep),  '--','color','y','LineWidth',2.5,'MarkerSize',5);hold on
d=plot(xmin:xmax-1,IRFd(:,2+Sdep),  '--','color','m','LineWidth',2.5,'MarkerSize',5);hold on
e=plot(xmin:xmax-1,IRFe(:,2+Sdep),  '--','color','cyan','LineWidth',2.5,'MarkerSize',5);hold on

plot([min(xlim()),max(xlim())],[0,0], 'k','LineWidth',0.25);

set(gca,'TickDir','in'); 
xlabel('Quarters');
set(gca,'YLIM', [-2 8]);
yticks([-2 0 2 4 6 8])
set(gca,'XTick',[0:1:xmax-1 ])
set(gca,'XLIM', [-inf inf], 'FontSize',16)
box off; grid off;
set(gcf, 'Color', 'w');
legend([ a b c d e], '(4,4)','(1,1)','(1,2)','(2,4)','(1,4)', 'Orientation','Vertical','Location','northwest');
myplot.PaperPositionMode = 'manual';
set(myplot,'Position',[50 50 1200 800]);
orient(myplot,'landscape')

saveas(myplot, 'FigureA9b', 'pdf')
saveas(myplot, 'FigureA9b', 'epsc')

%% Non-ZLB Regime

Sdep=0;
OPTIONS.H=xmax;
IRFa=IRFa(1:xmax,:);
IRFb=IRFb(1:xmax,:);

r_color = 235;
b_color = 235;
g_color = 255;

x = 0:1:OPTIONS.H-1;

myplot=figure(3);

if OPTIONS.ShadedBands==0
    lb68=plot(xmin:xmax-1,IRFa(:,3+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    ub68=plot(xmin:xmax-1,IRFa(:,4+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    lb95=plot(xmin:xmax-1,IRFa(:,5+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
    ub95=plot(xmin:xmax-1,IRFa(:,6+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
elseif OPTIONS.ShadedBands==1
    shadedplot(xmin:xmax-1,IRFa(:,3+Sdep)',IRFa(:,4+Sdep)',[r_color/255 b_color/255 g_color/255],[r_color/255 b_color/255 g_color/255]); hold on;
    plot(xmin:xmax-1,IRFa(:,5+Sdep),'b','MarkerSize',5); hold on;
    plot(xmin:xmax-1,IRFa(:,6+Sdep),'b','MarkerSize',5); hold on;
end

a=plot(xmin:xmax-1,IRFa(:,2+Sdep), 'b-o','LineWidth',2.5,'MarkerSize',8);hold on
b=plot(xmin:xmax-1,IRFb(:,2+Sdep),  '--','color','#2f7e2b','LineWidth',2.5,'MarkerSize',5);hold on
c=plot(xmin:xmax-1,IRFc(:,2+Sdep),  '--','color','y','LineWidth',2.5,'MarkerSize',5);hold on
d=plot(xmin:xmax-1,IRFd(:,2+Sdep),  '--','color','m','LineWidth',2.5,'MarkerSize',5);hold on
e=plot(xmin:xmax-1,IRFe(:,2+Sdep),  '--','color','cyan','LineWidth',2.5,'MarkerSize',5);hold on

plot([min(xlim()),max(xlim())],[0,0], 'k','LineWidth',0.25);

set(gca,'TickDir','in');
xlabel('Quarters');
set(gca,'YLIM', [-1 6]);
yticks([ 0 2 4 6 ])
set(gca,'XTick',[0:1:xmax-1 ])
set(gca,'XLIM', [-inf inf], 'FontSize',16)
box off; grid off;
set(gcf, 'Color', 'w');
legend([ a b c d e], '(4,4)','(1,1)','(1,2)','(2,4)','(1,4)', 'Orientation','Vertical','Location','northwest');
myplot.PaperPositionMode = 'manual';
set(myplot,'Position',[50 50 1200 800]);
orient(myplot,'landscape')

saveas(myplot, 'FigureA9c', 'pdf')
saveas(myplot, 'FigureA9c', 'epsc')


